package com.example.javabasic.common.exception;

import com.example.javabasic.common.data.ResultData;
import com.example.javabasic.common.data.StatusCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author: cph
 * @date: 2022/2/15 14:53
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public ResultData errorHandler(Exception e) {
        log.error("errorHandler", e);
        return ResultData.failure(StatusCodeEnum.FAILURE);
    }

}
